﻿namespace HiMap.Carto
{
    using System;
    using System.Text;

    public class FieldsClass : IFields
    {
        protected internal ClassClass _Class;

        public FieldsClass()
        {
            this._Class = null;
        }

        protected internal FieldsClass(IFeatureClass Class)
        {
            this._Class = (ClassClass) Class;
        }

        int IFields.FindField(string Name)
        {
            for (int i = 0; i < ((IFields) this).FieldCount; i++)
            {
                if (this.GetField(i).Name.ToUpper() == Name.ToUpper())
                {
                    return i;
                }
            }
            return -1;
        }

        IField IFields.GetField(int Index)
        {
            StringBuilder builder = new StringBuilder(0xff);
            VC.KWG_FEATURELAYER_GET_FIELD_NAME(this._Class.InPtr, Index, builder);
            return new FieldClass((FieldType) VC.KWG_FEATURELAYER_GET_FIELD_TYPE(this._Class.InPtr, Index), builder.ToString());
        }

        int IFields.FieldCount
        {
            get
            {
                return VC.KWG_FEATURELAYER_GET_FIELD_COUNT(this._Class.InPtr);
            }
        }
    }
}

